class Vehicle {
    brand: string;
    year: string;
    private isFutureYear: boolean;
    static vehicleCount: number = 0;

    constructor(brand: string, year: string) {
        this.brand = brand;
        this.year = year;
        this.isFutureYear = this.checkFutureYear();
        Vehicle.vehicleCount++;
    }

    private checkFutureYear(): boolean {
        const yearNumber = parseInt(this.year);
        const currentYear = new Date().getFullYear();
        return yearNumber > currentYear;
    }

    futureYear(): void {
        if (this.isFutureYear) {
            console.log('不合理');
        } else {
            console.log('合理');
        }
    }

    getInfo() {
        console.log(`Brand: ${this.brand}, Year: ${this.year}`);
    }

    static incrementVehicleCount(): void {
        Vehicle.vehicleCount++;
    }
}

export class Car extends Vehicle {
    mileage: number;

    constructor(brand: string, year: string, mileage: number) {
        super(brand, year);
        this.mileage = mileage;
    }

    get mileageGetter(): number {
        return this.mileage;
    }

    set mileageSetter(value: number) {
        this.mileage = value;
    }

    drive(distance: number) {
        this.mileage += distance;
    }

    getInfo(): void {
        super.getInfo();
        console.log(`Mileage: ${this.mileage}`);
    }

    static compareMileage(car1: Car, car2: Car): Car {
        return car1.mileage > car2.mileage ? car1 : car2;
    }
}

const car1 = new Car("Toyota", "2020", 50000);
const car2 = new Car("Honda", "2030", 70000);

car1.futureYear();
car2.futureYear();


car2.drive(10000);


const higherMileageCar = Car.compareMileage(car1, car2);
higherMileageCar.getInfo();

Car.incrementVehicleCount();
console.log(`Current vehicle count: ${Car.vehicleCount}`);